﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using Xceed.Wpf.Toolkit.PropertyGrid.Editors;
using WhiteRepositoryExplorer.Views;

namespace WhiteRepositoryExplorer.Model
{
    public class WhiteControl
    {
        private readonly string _id;
        private readonly WhiteControlProperties _properties;
        private readonly string _controlType;
        private readonly int _ordinalNumber;
        private readonly string _description;
        private readonly string _imagePath;

        public WhiteControl(string id, WhiteControlProperties properties, string controlType, int ordinalNumber)
        {
            _id = id;
            _properties = properties;
            _controlType = controlType;
            _ordinalNumber = ordinalNumber;
        }

        public WhiteControl(string id, WhiteControlProperties properties, string controlType, int ordinalNumber, string description, string imagePath) :
            this(id,properties,controlType,ordinalNumber)
        {
            _description = description;
            _imagePath = imagePath;
        }

        [Editor(typeof(ReadOnlyTextEditor), typeof(ReadOnlyTextEditor))]
        [Description("Unique (int the XML scope) control attribute of string format")]
        public string Id
        {
            get { return _id; }
        }

        [Browsable(false)]
        [Description("'properties' attribute of 'Control' tag in XML, which contains all the automation properties (except 'ControlType'), separated by '|'. Can be empty, but must be declared.")]
        public WhiteControlProperties Properties
        {
            get { return _properties; }
        }

        [Editor(typeof(ReadOnlyTextEditor), typeof(ReadOnlyTextEditor))]
        [Description("'controltype' attribute of 'Control' tag in XML. Required. Must contain a value from 'ControlType'.")]
        public string ControlType
        {
            get { return _controlType; }
        }

        [Editor(typeof(ReadOnlyTextEditor), typeof(ReadOnlyTextEditor))]
        [Description("'description' attribute of 'Control' tag. Optional, can be empty.")]
        public string Description
        {
            get { return _description; }
        }

        [Editor(typeof(ReadOnlyTextEditor), typeof(ReadOnlyTextEditor))]
        [Description("'image' attribute of 'Control' tag. Optional. If controls a name of non-existing image, then placeholder image is shown. Image name must be in format 'image1.png' which is used to show image (if exists) from the 'images' folder, which must be located in the same folder as XML")]
        public string ImagePath
        {
            get { return _imagePath; }
        }

        [Editor(typeof(ReadOnlyTextEditor), typeof(ReadOnlyTextEditor))]
        [Description("Ordinal number which is used to know in which order which control is faced in the XML")]
        public int OrdinalNumber
        {
            get { return _ordinalNumber; }
        }
    }
}
